﻿using Entity.WMS.DTO.WarehouseOtherOut;
using Entity.WMS.View.WarehouseOtherOut;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Service.WMS;

namespace AnQinManagermentBackendAPI.Controller.WMS
{
    /// <summary>
    /// 其他出库表
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    public class WarehouseOtherOutController : ControllerBase
    {
        /**
         * 其他出库业务接口
         */
        private readonly WarehouseOtherOutService _warehouseOtherOutService;

        /**
         * 构造函数注入
         */
        public WarehouseOtherOutController(WarehouseOtherOutService warehouseOtherOutService)
        {
            _warehouseOtherOutService = warehouseOtherOutService;
        }

        /// <summary>
        /// 获取其他出库列表
        /// </summary>
        /// <param name="warehouseOtherOutSearchDTO"></param>
        [HttpGet]
        [ProducesResponseType(typeof(WarehouseOtherOutView), 200)]
        public async Task<IActionResult> GetWarehouseOtherOutList([FromQuery] WarehouseOtherOutSearchDTO warehouseOtherOutSearchDTO)
        {
            var response = await _warehouseOtherOutService.GetWarehouseOtherOutList(warehouseOtherOutSearchDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 获取其他出库子单列表
        /// </summary>
        /// <param name="warehouseOtherOutItemSearchDTO"></param>
        [HttpGet("item")]
        [ProducesResponseType(typeof(WarehouseOtherOutItemView), 200)]
        public async Task<IActionResult> GetWarehouseOtherOutItemList([FromQuery] WarehouseOtherOutItemSearchDTO warehouseOtherOutItemSearchDTO)
        {
            var response = await _warehouseOtherOutService.GetWarehouseOtherOutItemList(warehouseOtherOutItemSearchDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 新增其他出库
        /// </summary>
        /// <param name="warehouseOtherOutAddDTO"></param>
        [HttpPost]
        public async Task<IActionResult> AddWarehouseOtherIn([FromBody] WarehouseOtherOutAddDTO warehouseOtherOutAddDTO)
        {
            var response = await _warehouseOtherOutService.AddWarehouseOtherOut(warehouseOtherOutAddDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 删除其他出库
        /// </summary>
        [HttpDelete]
        public async Task<IActionResult> DeleteWarehouseOtherOut([FromQuery] string Id)
        {
            var response = await _warehouseOtherOutService.DeleteWarehouseOtherOut(Id);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 审核通过其他出库
        /// </summary>
        [HttpPost("Pass")]
        public async Task<IActionResult> PassWarehouseOtherOut([FromBody] string Id)
        {
            var response = await _warehouseOtherOutService.PassWarehouseOtherOut(Id);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 审核不通过其他出库
        /// </summary>
        [HttpPost("UnPass")]
        public async Task<IActionResult> UnPassWarehouseOtherOut([FromBody] string Id)
        {
            var response = await _warehouseOtherOutService.UnPassWarehouseOtherOut(Id);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 反审核其他出库
        /// </summary>
        [HttpPost("CancelPass")]
        public async Task<IActionResult> CancelWarehouseOtherOut([FromBody] string Id)
        {
            var response = await _warehouseOtherOutService.CancelPassWarehouseOtherOut(Id);
            return StatusCode(response.Status, response);
        }
    }
}
